Skip to content

Update ExplicitMoleculeComponent warning to provide molecule name#720

Open
jaclark5 wants to merge 2 commits intoOpenFreeEnergy:mainfrom
jaclark5:hyd_warning
Open

Update ExplicitMoleculeComponent warning to provide molecule name#720
jaclark5 wants to merge 2 commits intoOpenFreeEnergy:mainfrom
jaclark5:hyd_warning

Conversation

@jaclark5
Copy link

Previously ExplicitMoleculeComponent has a warning:

UserWarning: Molecule doesn't have any hydrogen atoms present. If this is unexpected, consider loading the molecule with `removeHs=False`
  warnings.warn(

now it is more meaningful by listing the molecule name with it.

UserWarning: Molecule, Structure37_mol2, doesn't have any hydrogen atoms present. If this is unexpected, consider loading the molecule with `removeHs=False`
  warnings.warn(

Tips

  • Comment "pre-commit.ci autofix" to have pre-commit.ci atomically format your PR.
    Since this will create a commit, it is best to make this comment when you are finished with your work.

Checklist

  • Added a news entry

Developers certificate of origin

if not any(atom.GetAtomicNum() == 1 for atom in rdkit.GetAtoms()):
warnings.warn(
"Molecule doesn't have any hydrogen atoms present. "
f"Molecule, {name}, doesn't have any hydrogen atoms present. "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Molecule, {name}, doesn't have any hydrogen atoms present. "
f"Molecule (name='{name}') doesn't have any hydrogen atoms present. "

It's valid for the name to be an empty string, so this should make the message less confusing in that case.

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

No API break detected ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants